package cn.zy.chapter2.service;

import cn.zy.chapter2.model.Customer;
import cn.zy.framework.annotation.Service;
import cn.zy.framework.helper.DatabaseHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;

/**
 * @Author: Administrator
 * @Description:
 * @Date: Created in 16:22 2021/9/9
 * @Modified By:
 * @version: 1.0
 */
@Service
public class CustomerService {

	private static final Logger LOG = LoggerFactory.getLogger(CustomerService.class);

	public List<Customer> getCustomerList() {

			String sql="select * from customer";
			return DatabaseHelper.queryEntityList(Customer.class, sql);
	}

	public Customer getCustomer(long id) {

		String sql="select * from customer where id=?";
		return DatabaseHelper.queryEntity(Customer.class, sql, id);
	}

	/**
	 * 创建客户
	 * @param fieldMap
	 * @return
	 */
	public boolean createCustomer(Map<String, Object> fieldMap){

		return DatabaseHelper.insertEntity(Customer.class, fieldMap);
	}


	public boolean updateCustomer(long id, Map<String, Object> fieldMap){

		return DatabaseHelper.updateEntity(Customer.class, id, fieldMap);
	}

	public boolean deleteCustomer(long id) {

		return DatabaseHelper.deleteEntity(Customer.class, id);
	}


}
